/*
 *  * Copyright (C) 2021 Huawei Device Co., Ltd.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

package com.beardedhen.harmonybootstrap.utils;

import ohos.agp.colors.RgbColor;
import ohos.agp.components.element.ShapeElement;
import ohos.app.Context;

public class UiUtil {
    private static final String TAG = UiUtil.class.getSimpleName();
    private Context mContext;

    public UiUtil(Context context) {
        LogUtil.info(TAG, "Entering UiUtil");
        mContext = context;
    }

   public final ShapeElement getShapeElement(int shape, int color, float radius) {
        LogUtil.info(TAG, "Entering getShapeElement");
        ShapeElement shapeElement = new ShapeElement();
        shapeElement.setShape(shape);
        shapeElement.setRgbColor(RgbColor.fromArgbInt(ResUtil.getColor(mContext, color)));
        shapeElement.setCornerRadius(radius);
        return shapeElement;
    }

    public static int getBootstrapSizeInt(String bootstrapSizeStr) {
        switch (bootstrapSizeStr) {
            case "xs":
                return 0;
            case "sm":
                return 1;
            case "md":
                return 2;
            case "lg":
                return 3;
            case "xl":
                return 4;
            default:
                return 2;
        }
    }

    public static int getBootstrapBrandInt(String bootstrapBrandStr) {
        bootstrapBrandStr = bootstrapBrandStr.toLowerCase();
        switch (bootstrapBrandStr) {
            case "primary":
                return 0;
            case "success":
                return 1;
            case "info":
                return 2;
            case "warning":
                return 3;
            case "danger":
                return 4;
            case "regular":
                return 5;
            case "secondary":
                return 6;
            default:
                return 5;
        }

    }

    public static int getBootstrapHeadingInt(String bootstrapHeadingStr) {
        bootstrapHeadingStr = bootstrapHeadingStr.toLowerCase();
        switch (bootstrapHeadingStr) {
            case "h1":
                return 0;
            case "h2":
                return 1;
            case "h3":
                return 2;
            case "h4":
                return 3;
            case "h5":
                return 4;
            case "h6":
                return 5;
            default:
                return 5;
        }

    }

    public static int getBootstrapButtonModeInt(String bootstrapButtonModeStr) {
        bootstrapButtonModeStr = bootstrapButtonModeStr.toLowerCase();
        switch (bootstrapButtonModeStr) {
            case "regular":
                return 0;
            case "toggle":
                return 1;
            case "checkbox":
                return 2;
            case "radio":
                return 3;
            default:
                return 0;
        }

    }
}